import uicls
import uiconst

class Slider(uicls.SliderCore):
    __guid__ = 'uicls.Slider'
    default_minValue = 0.0
    default_maxValue = 1.0

    def Prepare_Underlay_(self):
        self.frame = uicls.Frame(parent=self, align=uiconst.TOBOTTOM, pos=(0, 0, 0, 6), padding=(0, 0, 0, 5), color=(1.0, 1.0, 1.0, 0.3), state=uiconst.UI_NORMAL)
        self.frame.OnClick = self.OnFrameClicked



    def OnFrameClicked(self, *args):
        (l, t, w, h,) = self.frame.GetAbsolute()
        localMousePos = (uicore.triapp.uilib.x - l)
        x = (localMousePos / float(w))
        newValue = (self.minValue + (x * (self.maxValue - self.minValue)))
        self.SetValue(newValue, updateHandle=True)
        self.EndSetSliderValue(self)



    def Prepare_Label_(self):
        self.label = uicls.Label(parent=self, font=self.font, fontsize=self.fontsize, pos=(self.labeltab,
         2,
         0,
         0), autowidth=False, autoheight=False, state=uiconst.UI_NORMAL)




